package com.base.caselib;

import android.support.v7.widget.LinearLayoutManager;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.base.caselib.bean.Process;
import com.base.caselib.databinding.ActivityCaseProcessBinding;
import com.base.caselib.presenter.CaseProcessPresenter;
import com.base.caselib.view.CaseProcessView;
import com.base.commonlib.base.CBaseBarMvpActivity;
import com.base.commonlib.base.adapter.BaseAdapter;
import com.base.commonlib.base.adapter.BaseHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zw on 2019/10/29.
 * 案件流程
 */
@Route(path = "/case/caseprocess")
public class CaseProcessActivity extends CBaseBarMvpActivity<CaseProcessPresenter> implements CaseProcessView {
    private List<Process> mProcesses = new ArrayList<>();
    private BaseAdapter<Process> mAdapter;
    private ActivityCaseProcessBinding mBinding;

    @Autowired()
    public String id;


    @Override
    protected int getLayoutResource() {
        return R.layout.activity_case_process;
    }

    @Override
    protected void start() {
        mBinding = (ActivityCaseProcessBinding) mRootBinding;
        setBackNavigation();
        setBarTitle("流程");
        mPresenter = new CaseProcessPresenter(this, this);
        mPresenter.getCaseProcess(id);
    }



    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mPresenter != null) {
            mPresenter.release();
        }

    }

    @Override
    public void returnCaseProcessBean(List<Process> bean) {
        mAdapter = new BaseAdapter<Process>(bean, mContext) {
            @Override
            public void convert(BaseHolder holder, Process process, boolean isHeader, boolean isBottom) {
                TextView tv_time = holder.getView(R.id.tv_show_time);
                TextView tv_path_name = holder.getView(R.id.tv_path_name);
                TextView tv_person_name = holder.getView(R.id.tv_person_name);
                TextView tv_advice = holder.getView(R.id.tv_advice);
                tv_time.setText(process.getAppTime());
                tv_path_name.setText(process.getAgree());
                tv_person_name.setText(process.getProValue());
                tv_advice.setText(process.getAppContent());
            }
        };




        mAdapter.putNormalType(R.layout.item_process);
        mBinding.rv.setLayoutManager(new LinearLayoutManager(mContext));
        mBinding.rv.setAdapter(mAdapter);
    }
}
